package net.toocruel.iqismart.service.helper;

import net.toocruel.iqismart.service.dto.SessionMessage;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Description
 * @Auther sty
 * @createTime 2018/5/18 下午2:37
 */
public class MessageHelp {
    public static void putSessionMessage(SessionMessage sessionMessage){
        HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
        HttpSession session = request.getSession();
        session.setAttribute("message",sessionMessage);
    }

    public static void cleanSessionMessage() {
        HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
        HttpSession session = request.getSession();
        session.removeAttribute("message");
    }
}
